/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'regional';
  
  checkConfig(config);
  @endpoint = getEndpoint('virtualhumanalgorithms', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model BuildRealisticModelFromWebPicRequest {
  algorithmVersion?: string(name='AlgorithmVersion', example='0.1'),
  bodyPicUrl?: string(name='BodyPicUrl', example='http://baidu.com/pic/3434'),
  facePicUrl?: string(name='FacePicUrl', example='http://third.peass.cn/testImg/500231200701151451.png'),
  from?: string(name='From', example='aqs'),
  gender?: string(name='Gender', example='M'),
  height?: double(name='Height', example='174'),
  ossUploadPolicy?: {
    accessId?: string(name='AccessId', example='0dc904d9-33b6-4a94-b920-2b2df720ab89'),
    dir?: string(name='Dir', example='asc'),
    expire?: string(name='Expire', example='1101'),
    host?: string(name='Host', example='https://mps-zjk-share.oss-cn-zhangjiakou.aliyuncs.com'),
    policy?: string(name='Policy', example='fadfdsafadf'),
    signature?: string(name='Signature', example='jkMDo2CnhBoODbldmmmuSx5xImw='),
  }(name='OssUploadPolicy'),
  sideBodyPicUrl?: string(name='SideBodyPicUrl', example='http://baidu.com/pic/3434'),
  weight?: double(name='Weight', example='60'),
}

model BuildRealisticModelFromWebPicShrinkRequest {
  algorithmVersion?: string(name='AlgorithmVersion', example='0.1'),
  bodyPicUrl?: string(name='BodyPicUrl', example='http://baidu.com/pic/3434'),
  facePicUrl?: string(name='FacePicUrl', example='http://third.peass.cn/testImg/500231200701151451.png'),
  from?: string(name='From', example='aqs'),
  gender?: string(name='Gender', example='M'),
  height?: double(name='Height', example='174'),
  ossUploadPolicyShrink?: string(name='OssUploadPolicy'),
  sideBodyPicUrl?: string(name='SideBodyPicUrl', example='http://baidu.com/pic/3434'),
  weight?: double(name='Weight', example='60'),
}

model BuildRealisticModelFromWebPicResponseBody = {
  code?: string(name='Code', example='0'),
  data?: {
    jobId?: string(name='JobId', example='RUIF5K5GLZH86GI2'),
    jobState?: string(name='JobState', example='Finished'),
  }(name='Data'),
  errorMessage?: string(name='ErrorMessage', example='ip, user, pwd is empty or error'),
  httpCode?: string(name='HttpCode', example='200'),
  requestId?: string(name='RequestId', example='8E33801B-248E-5103-8B00-1D0FD991DD03'),
  success?: boolean(name='Success', example='True'),
}

model BuildRealisticModelFromWebPicResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: BuildRealisticModelFromWebPicResponseBody(name='body'),
}

async function buildRealisticModelFromWebPicWithOptions(tmpReq: BuildRealisticModelFromWebPicRequest, runtime: Util.RuntimeOptions): BuildRealisticModelFromWebPicResponse {
  Util.validateModel(tmpReq);
  var request = new BuildRealisticModelFromWebPicShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.ossUploadPolicy)) {
    request.ossUploadPolicyShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.ossUploadPolicy, 'OssUploadPolicy', 'json');
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.algorithmVersion)) {
    body['AlgorithmVersion'] = request.algorithmVersion;
  }
  if (!Util.isUnset(request.bodyPicUrl)) {
    body['BodyPicUrl'] = request.bodyPicUrl;
  }
  if (!Util.isUnset(request.facePicUrl)) {
    body['FacePicUrl'] = request.facePicUrl;
  }
  if (!Util.isUnset(request.from)) {
    body['From'] = request.from;
  }
  if (!Util.isUnset(request.gender)) {
    body['Gender'] = request.gender;
  }
  if (!Util.isUnset(request.height)) {
    body['Height'] = request.height;
  }
  if (!Util.isUnset(request.ossUploadPolicyShrink)) {
    body['OssUploadPolicy'] = request.ossUploadPolicyShrink;
  }
  if (!Util.isUnset(request.sideBodyPicUrl)) {
    body['SideBodyPicUrl'] = request.sideBodyPicUrl;
  }
  if (!Util.isUnset(request.weight)) {
    body['Weight'] = request.weight;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'BuildRealisticModelFromWebPic',
    version = '2022-12-29',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function buildRealisticModelFromWebPic(request: BuildRealisticModelFromWebPicRequest): BuildRealisticModelFromWebPicResponse {
  var runtime = new Util.RuntimeOptions{};
  return buildRealisticModelFromWebPicWithOptions(request, runtime);
}

model CreateCartoonModelTaskRequest {
  gender?: string(name='Gender', example='M'),
  picUrl?: string(name='PicUrl', example='https://alitar-new.oss-cn-shanghai.aliyuncs.com/client/images/2022-12-30/IMG_20220622_161021.jpg?Expires=1672398027&OSSAccessKeyId=LTAI5tL7pDDbxQd4m6Y5zqov&Signature=B6XoH59dcwZ8CzN%2BmnZEMOzvRK0%3D'),
}

model CreateCartoonModelTaskResponseBody = {
  code?: string(name='Code', example='0'),
  data?: {
    taskId?: string(name='TaskId', example='30c0a39f-9310-4a45-b34d-19b6e834c168'),
    taskState?: string(name='TaskState', example='running'),
  }(name='Data'),
  errorMessage?: string(name='ErrorMessage', example='projectName invalid'),
  httpCode?: string(name='HttpCode', example='200'),
  requestId?: string(name='RequestId', example='97A4162C-2F54-5C19-94D3-44B6C5B0E8FB'),
  success?: boolean(name='Success', example='True'),
}

model CreateCartoonModelTaskResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CreateCartoonModelTaskResponseBody(name='body'),
}

async function createCartoonModelTaskWithOptions(request: CreateCartoonModelTaskRequest, runtime: Util.RuntimeOptions): CreateCartoonModelTaskResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.gender)) {
    body['Gender'] = request.gender;
  }
  if (!Util.isUnset(request.picUrl)) {
    body['PicUrl'] = request.picUrl;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateCartoonModelTask',
    version = '2022-12-29',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function createCartoonModelTask(request: CreateCartoonModelTaskRequest): CreateCartoonModelTaskResponse {
  var runtime = new Util.RuntimeOptions{};
  return createCartoonModelTaskWithOptions(request, runtime);
}

model QueryCartoonModelTaskRequest {
  taskId?: string(name='TaskId', example='0a7ca037-7d32-4f84-a03c-06a8acd0dd62'),
}

model QueryCartoonModelTaskResponseBody = {
  code?: string(name='Code', example='0'),
  data?: {
    gender?: string(name='Gender', example='F'),
    properTypes?: map[string]any(name='ProperTypes'),
    shapeParams?: map[string]any(name='ShapeParams'),
    taskId?: string(name='TaskId', example='30c0a39f-9310-4a45-b34d-19b6e834c168'),
    taskState?: string(name='TaskState', example='RUNNING'),
  }(name='Data'),
  errorMessage?: string(name='ErrorMessage', example='projectName invalid'),
  httpCode?: string(name='HttpCode', example='200'),
  requestId?: string(name='RequestId', example='44AC83A6-E014-517E-80C8-C3591F598196'),
  success?: boolean(name='Success', example='True'),
}

model QueryCartoonModelTaskResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: QueryCartoonModelTaskResponseBody(name='body'),
}

async function queryCartoonModelTaskWithOptions(request: QueryCartoonModelTaskRequest, runtime: Util.RuntimeOptions): QueryCartoonModelTaskResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.taskId)) {
    query['TaskId'] = request.taskId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'QueryCartoonModelTask',
    version = '2022-12-29',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryCartoonModelTask(request: QueryCartoonModelTaskRequest): QueryCartoonModelTaskResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryCartoonModelTaskWithOptions(request, runtime);
}

model VerifyBodyBase64PicRequest {
  base64?: string(name='Base64', example='fdsafdafd'),
  fileName?: string(name='FileName', example='aaa.jpg'),
}

model VerifyBodyBase64PicResponseBody = {
  code?: string(name='Code', example='0'),
  errorMessage?: string(name='ErrorMessage', example='ip, user, pwd is empty or error'),
  httpCode?: string(name='HttpCode', example='200'),
  requestId?: string(name='RequestId', example='8E33801B-248E-5103-8B00-1D0FD991DD03'),
  success?: boolean(name='Success', example='True'),
}

model VerifyBodyBase64PicResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: VerifyBodyBase64PicResponseBody(name='body'),
}

async function verifyBodyBase64PicWithOptions(request: VerifyBodyBase64PicRequest, runtime: Util.RuntimeOptions): VerifyBodyBase64PicResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.base64)) {
    body['Base64'] = request.base64;
  }
  if (!Util.isUnset(request.fileName)) {
    body['FileName'] = request.fileName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'VerifyBodyBase64Pic',
    version = '2022-12-29',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function verifyBodyBase64Pic(request: VerifyBodyBase64PicRequest): VerifyBodyBase64PicResponse {
  var runtime = new Util.RuntimeOptions{};
  return verifyBodyBase64PicWithOptions(request, runtime);
}

model VerifyFaceBase64PicRequest {
  base64?: string(name='Base64', example='fdafd'),
  fileName?: string(name='FileName', example='aaa.jpg'),
}

model VerifyFaceBase64PicResponseBody = {
  code?: string(name='Code', example='0'),
  errorMessage?: string(name='ErrorMessage', example='projectName invalid'),
  httpCode?: string(name='HttpCode', example='200'),
  requestId?: string(name='RequestId', example='97A4162C-2F54-5C19-94D3-44B6C5B0E8FB'),
  success?: boolean(name='Success', example='True'),
}

model VerifyFaceBase64PicResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: VerifyFaceBase64PicResponseBody(name='body'),
}

async function verifyFaceBase64PicWithOptions(request: VerifyFaceBase64PicRequest, runtime: Util.RuntimeOptions): VerifyFaceBase64PicResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.base64)) {
    body['Base64'] = request.base64;
  }
  if (!Util.isUnset(request.fileName)) {
    body['FileName'] = request.fileName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'VerifyFaceBase64Pic',
    version = '2022-12-29',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function verifyFaceBase64Pic(request: VerifyFaceBase64PicRequest): VerifyFaceBase64PicResponse {
  var runtime = new Util.RuntimeOptions{};
  return verifyFaceBase64PicWithOptions(request, runtime);
}

model VerifySideBodyBase64PicRequest {
  base64?: string(name='Base64', example='fdafdf'),
  fileName?: string(name='FileName', example='aaa.jpg'),
}

model VerifySideBodyBase64PicResponseBody = {
  code?: string(name='Code', example='0'),
  errorMessage?: string(name='ErrorMessage', example='ip, user, pwd is empty or error'),
  httpCode?: string(name='HttpCode', example='200'),
  requestId?: string(name='RequestId', example='8E33801B-248E-5103-8B00-1D0FD991DD03'),
  success?: boolean(name='Success', example='True'),
}

model VerifySideBodyBase64PicResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: VerifySideBodyBase64PicResponseBody(name='body'),
}

async function verifySideBodyBase64PicWithOptions(request: VerifySideBodyBase64PicRequest, runtime: Util.RuntimeOptions): VerifySideBodyBase64PicResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.base64)) {
    body['Base64'] = request.base64;
  }
  if (!Util.isUnset(request.fileName)) {
    body['FileName'] = request.fileName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'VerifySideBodyBase64Pic',
    version = '2022-12-29',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function verifySideBodyBase64Pic(request: VerifySideBodyBase64PicRequest): VerifySideBodyBase64PicResponse {
  var runtime = new Util.RuntimeOptions{};
  return verifySideBodyBase64PicWithOptions(request, runtime);
}

